package com.baidibaidi;

import us.pinguo.edit.sdk.PGEditImageLoader;
import us.pinguo.edit.sdk.base.PGEditSDK;
import android.app.Application;
import android.graphics.Bitmap.CompressFormat;

import com.nostra13.universalimageloader.cache.memory.impl.UsingFreqLimitedMemoryCache;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;

public class MyApplication extends Application {
	public static ImageLoader imageLoader = ImageLoader.getInstance();

	@Override
	public void onCreate() {
		super.onCreate();
		PGEditImageLoader.initImageLoader(this);
		PGEditSDK.instance().initSDK(this);

		ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
				getApplicationContext())
				.threadPoolSize(5)
				// 设置线程池的最高线程数量
				.diskCacheExtraOptions(480, 800, null)
				// .discCacheExtraOptions(480, 800, CompressFormat.JPEG, 70)
				// 设置硬盘缓存，默认格式jpeg，压缩质量70
				.threadPriority(Thread.NORM_PRIORITY - 2)
				.memoryCache(new UsingFreqLimitedMemoryCache(4 * 1024 * 1024))// 设置缓存大小，UsingFrgLimitMemoryCache类可以扩展
				.denyCacheImageMultipleSizesInMemory()

				.tasksProcessingOrder(QueueProcessingType.LIFO)
				// .writeDebugLogs()
				// .enableLogging() //
				.build();

		ImageLoader.getInstance().init(config);

	}
}
